package com.xf.pub.exception.base;

import com.xf.pub.exception.ExceptionMessageFactory;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Properties;

public class ExceptionResource
{
  private static Properties prop;

  public static String getExceptionMessage(String errorCode)
  {
    return prop.getProperty(errorCode).trim();
  }

  public static String getExceptionMessage(String errorCode, String Default) {
    return prop.getProperty(errorCode, Default).trim();
  }

  public ExceptionResource()
  {
    prop = new Properties();
    InputStream in = ExceptionMessageFactory.class.getClassLoader().getResourceAsStream("serviceException.properties");
    try
    {
      prop.load(in);
    } catch (IOException e) {
      System.out.println("No serviceException.properties defined error");
    }
  }

  public ExceptionResource(String resourceName)
  {
    prop = new Properties();
    InputStream in = ExceptionMessageFactory.class.getClassLoader().getResourceAsStream(resourceName);
    try
    {
      prop.load(in);
    } catch (IOException e) {
      System.out.println("No serviceException.properties defined error");
    }
  }
}